<template>
	<view class="p24">
		<u-form :model="form" ref="uForm" labelWidth="auto" :clearable="false" :borderBottom="false">
			<view class="fs30 tit-ac ml20 relative mb22">
				<text>请填写本人身份信息</text>
			</view>
			<!--
			<view class="p24 flex bg-fff radius12 mb22">
				<view class="">真实姓名</view>
				<view class="tr flex1">
					<input placeholder="请输入真实姓名" for />
				</view>
			</view> -->
			<view class="pl20 pr20  bg-fff radius12 mb22">
				<u-form-item label="真实姓名" prop="name">
					<u-input v-model="form.name" inputAlign="right" :clearable="false" placeholder="请输入真实姓名" />
				</u-form-item>
			</view>
			<view class="pl20 pr20  bg-fff radius12 mb22 ">
				<u-form-item label="身份证号" prop="card_no">
					<u-input v-model="form.card_no" type="idcard" maxlength="18" inputAlign="right" :clearable="false"
						placeholder="请输入身份证号" />
				</u-form-item>
			</view>

			<view class="fs30 tit-ac ml20 relative mb22">
				<text>请上传身份证</text>
			</view>
			<view class="p24 bg-fff radius12 mb22">
				<view class=" mb22 flex col-top">
					<view class="">身份证头像面</view>
					<view class="flex row-center flex1">
						<imgList @success="ids=>form.card_pros=ids" width="358" height="270"
							:src="'/static/img/index/sfz1.png'" />
					</view>
				</view>

				<view class="mb22 flex col-top">
					<view class="">身份证国徽面</view>
					<view class="flex row-center flex1">
						<imgList @success="ids=>form.card_cons=ids" width="358" height="270"
							:src="'/static/img/index/sfz2.png'" />
					</view>
				</view>
			</view>
			<view class="fs30 tit-ac ml20 relative mb22">
				<text>请填写个人资料</text>
			</view>

			<view class="pl20 pr20  bg-fff radius12 mb22 ">
				<u-form-item label="手机号码" prop="mobile">
					<u-input v-model="form.mobile" type="number" maxlength="11" inputAlign="right" :clearable="false"
						placeholder="请输入手机号码" />
				</u-form-item>
			</view>
			<view class="pl20 pr20  bg-fff radius12 mb22 ">
				<u-form-item label="机构" prop="organ_id">
					<u-input :value="organText(form.organ_id)" @click="getOrgan('click')" :selectOpen="organShow"
						type="select" inputAlign="right" :clearable="false" placeholder="请选择机构" />
				</u-form-item>
				<u-select :list="organList" v-model="organShow" @confirm="organSet" labelName="name" valueName="id">
				</u-select>
			</view>
			<view class="pl20 pr20  bg-fff radius12 mb22 ">
				<u-form-item label="陪诊项目" rightIcon="arrow-right">
					<u-input :value="servicesName" @click="getHospital()" disabled inputAlign="right" :clearable="false"
						placeholder="请选择陪诊项目" />
					<!-- <u-icon name="arrow-right" @click="getHospital()" /> -->
				</u-form-item>
			</view>
			<view class="pl20 pr20  bg-fff radius12 mb22 ">
				<u-form-item label="护龄" prop="service_year">
					<u-input v-model="form.service_year" type="number" inputAlign="right" :clearable="false"
						placeholder="请输入护龄" />
				</u-form-item>
			</view>
			<view class="pl20 pr20  bg-fff radius12 mb22 ">
				<u-form-item label="家庭住址" prop="address">
					<u-input v-model="form.address" inputAlign="right" :clearable="false" placeholder="请输入家庭住址" />
				</u-form-item>
			</view>

			<view class="fs30 tit-ac ml20 relative mb22">
				<text>请上传资格证书</text>
			</view>
			<view class="p24 bg-fff radius12 mb22">
				<imgList max="2" @success="e=>form.certificate=e" />
			</view>
			<view class="fs30 tit-ac ml20 relative mb22 flex ">
				<view class="flex1">请上传体检报告</view>
				<view class="color-red">*</view>
				<view class="fs24 color-999">请上传近3个月的体检报告</view>
			</view>
			<view class="p24 bg-fff radius12 mb22">
				<imgList max="2" @success="e=>form.report=e" />
			</view>

			<view class="h120"></view>
			<view class="pf bottom0 left0  w-max flex">
				<view class="p24 flex1">
					<u-button type="warning" ripple @click="submit">立即认证</u-button>
				</view>
			</view>
		</u-form>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form: {
					city_id:this.$getCache('myAdd').id||'',
					organ_id: '', //	整型	非必填	-	-	机构id
					name: '', //	字符串	必填	-	-	真实姓名
					card_no: '', //	字符串	必填	-	-	身份证号
					card_pros: '', //	整型	必填	-	-	身份证正面
					card_cons: '', //	整型	必填	-	-	身份证反面
					mobile: '', //	字符串	必填	-	-	手机号
					services: '', //	数组	必填	-	-	医院项目数组：[['hospital_id':'1','service_id':[1,2,3],['hospital_id':'2','service_id':[1,2,3]]]]
					service_year: '', //	整型	必填	-	-	护龄
					address: '', //	字符串	必填	-	-	住址
					certificate: '', //	字符串	必填	-	-	资格证书（多个用,号隔开）
					report: '', //	整型	必填	-	-	体检报告
				},
				servicesName: '',
				organShow: false, //机构
				organList: [], //
			}
		},
		onReady() {
			this.$refs.uForm.setRules(this.$list('rules'));
		},
		onLoad() {},
		methods: {
			submit() {
				console.log(this.form)
				this.$refs.uForm.validate(valid => {
					if (!valid) return
					this.$request('/master/auth/masterAuth', this.form).then(res => {
						this.$msg(res.msg)
						setTimeout(this.$navBack, 1000)
					})
				});
			},
			//机构
			getOrgan(e) {
				if (e == 'click' && this.organList.length) return this.organShow = true
				this.$request('/master/commom/getOrgan').then(res => {
					this.organList = res.data
					if (e == 'click') this.organShow = true
				})
			},
			organSet(e) {
				this.form.organ_id = e[0].value
			},
			organText(id) {
				if (id && (!this.organList.length)) this.getOrgan()
				return this.organList?.find(e => e.id == id)?.name || id
			},
			//机构end
			getHospital() {
				uni.$off('setDome')
				uni.$off('setDomeName')
				uni.$once('setDome', e => this.form.services = e)
				uni.$once('setDomeName', e => this.servicesName = e)
				this.$u.route('/pages/my/serve/hospitalSel', {
					services: this.form.services && JSON.stringify(this.form.services) || ""
				})
			},
		}
	}
</script>

<style lang="scss">

</style>
